package pl.un4giv3n.mightvsmagic.entity;

import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@NamedQueries({
	@NamedQuery(name="find.activities.older.than", query="select ua from UserActivity ua where userId = :userId and timeDone > :time"),
	@NamedQuery(name="find.activities.between", query="select ua from UserActivity ua where userId = :userId and timeDone > :timeAfter and timeDone < :timeBefore")
})
@Entity
public class UserActivity {
	@Id
	@GeneratedValue
	private Long id;
	@Enumerated(EnumType.ORDINAL)
	private ActivityType activityType;
	private long timeDone;
	private Long userId;
	@Embedded
	private ActivityDetails details;
	
	UserActivity(){
	}
	
	public UserActivity(ActivityType type, long time, Long userId, ActivityDetails details){
		this.activityType = type;
		this.timeDone = time;
		this.userId = userId;
		this.details = details;
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public ActivityType getActivityType() {
		return activityType;
	}
	public void setActivityType(ActivityType activityType) {
		this.activityType = activityType;
	}
	public long getTimeDone() {
		return timeDone;
	}
	public void setTimeDone(long timeDone) {
		this.timeDone = timeDone;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public ActivityDetails getDetails() {
		return details;
	}

	public void setDetails(ActivityDetails details) {
		this.details = details;
	}
}
